// Copyright (C) joyinter
// All rights reserved.
// 
// Author : Jiang Li
// Date   : 2004-7-29

#ifndef __USERLIST_H_CLIENT_MAIN__
#define __USERLIST_H_CLIENT_MAIN__

#pragma once

#include <common/ui/listview.h>
#include <common/netmsg/netmsg.h>

class CJoyUserList;
class CJoyUserBoxItem;
class CJoyLabel;


//##ModelId=44C4B5D80399
class CJoyUserListField : public CJoyListViewField
{
protected:
	//##ModelId=44C4B5D8039B
    virtual void CM_Draw(Graphics& graph);
public:
	//##ModelId=44C4B5D803A9
    CJoyUserListField();
	//##ModelId=44C4B5D803AA
    virtual ~CJoyUserListField();
};

namespace JoyUserListFields
{
class StatusField;
class SexField;
class NicknameField;
class UsertitleField;
class LevelField;
class ScoreField;
class CreditField;
class WinField;
class LossField;
class BattleGroupField;
class UserNetwork;
class UserLadder;
};

//##ModelId=44C4B5D803D8
class CJoyUserItem : public CJoyListViewItem
{
protected:
	//##ModelId=44C4B5D803DA
    virtual void CM_Draw(Graphics& graph);
	//##ModelId=44C4B5D90001
    virtual void CM_Mouse(MouseMessage msg, const CPoint& pt);
public:
	//##ModelId=44C4B5D90005
    UINT    m_userId;
	//##ModelId=44C4B5D90010
    CStringW m_nickname;
	//##ModelId=44C4B5D90015
    CStringW m_userTitle;
	//##ModelId=44C4B5D9001A
    CStringW m_battleGroup;
	//##ModelId=44C4B5D90021
    int     m_level;
	//##ModelId=44C4B5D90022
    int     m_score;
	//##ModelId=44C4B5D90023
    int     m_credit;
	//##ModelId=44C4B5D9002E
    int     m_winTimes;
	//##ModelId=44C4B5D9002F
	int     m_lossTimes;
	//##ModelId=44C4B5D90030
    int     m_network;
	//##ModelId=44C4B5D9003E
    int     m_ladder;
	//##ModelId=44C4B5D9003F
    INT     m_VIP;
	//##ModelId=44C4B5D90041
    CJoyUserBoxItem*    m_cbItem;
	//##ModelId=44C4B5D9004F
    JoyMessage::UserSexType m_sex;
	//##ModelId=44C4B5D90054
	JoyMessage::UserStatus  m_status;

	//##ModelId=44C4B5D90058
    void DrawIcon(Graphics& graph, CJoyImagePtr& icon, CJoyListViewField* field);
	//##ModelId=44C4B5D9005F
    void DrawString(Graphics& graph, const CStringW& str, StringFormat& sf, Font& f, Brush& b, CJoyListViewField* field);
	//##ModelId=44C4B5D9007E
    void DrawInt(Graphics& graph, int i, StringFormat& sf, Font& f, Brush& b, CJoyListViewField* field);
public:
	//##ModelId=44C4B5D9008F
    CJoyUserItem(void);
	//##ModelId=44C4B5D9009D
    virtual ~CJoyUserItem(void);

	//##ModelId=44C4B5D900A0
    CJoyUserList* GetUserList() const
    {
        return (CJoyUserList*)m_listView;
    }
};

//##ModelId=44C4B5D900CB
class CJoyUserList :
    public CJoyListView
{
	DECLARE_DYNAMIC(CJoyUserList)
protected:
	//##ModelId=44C4B5D900DA
    virtual void CM_LoadSkin(CJoyXmlElement* pSkinElem);
	//##ModelId=44C4B5D900DD
    virtual void CM_SelItem(CJoyListViewItem* item);
public:
	//##ModelId=44C4B5D900E1
    Color   m_itemBackColor;
	//##ModelId=44C4B5D900EB
    Color   m_selTextColor;
	//##ModelId=44C4B5D900FB
    Color   m_selBackColor;

	//##ModelId=44C4B5D90100
    CJoyImagePtr    m_staChat;
	//##ModelId=44C4B5D9010A
    CJoyImagePtr    m_staPlay;
	//##ModelId=44C4B5D9010F
    CJoyImagePtr    m_sexMale;
	//##ModelId=44C4B5D90114
    CJoyImagePtr    m_sexFemale;
	//##ModelId=44C4B5D9011A
    CJoyImagePtr    m_sexUnknown;

	//##ModelId=44C4B5D9011F
    JoyUserListFields::StatusField*         m_statusField;
	//##ModelId=44C4B5D90129
    JoyUserListFields::SexField*            m_sexField;
	//##ModelId=44C4B5D9012E
    JoyUserListFields::NicknameField*       m_nicknameField;
	//##ModelId=44C4B5D90139
    JoyUserListFields::UsertitleField*      m_userTitleField;
	//##ModelId=44C4B5D9013E
    JoyUserListFields::LevelField*          m_levelField;
	//##ModelId=44C4B5D90149
    JoyUserListFields::ScoreField*          m_scoreField;
	//##ModelId=44C4B5D9014E
    JoyUserListFields::CreditField*         m_creditField;
	//##ModelId=44C4B5D90158
    JoyUserListFields::WinField*            m_winField;
	//##ModelId=44C4B5D90168
    JoyUserListFields::LossField*           m_lossField;
	//##ModelId=44C4B5D9016D
    JoyUserListFields::BattleGroupField*    m_battleGroupField;
	//##ModelId=44C4B5D90178
    JoyUserListFields::UserNetwork*         m_userNetwork;
	//##ModelId=44C4B5D9017D
    JoyUserListFields::UserLadder*          m_userLadderField;

    template<typename FieldType>
    void AddField_T(FieldType*& f, PCSTR name);
public:
	//##ModelId=44C4B5D90186
    CJoyUserList(void);
	//##ModelId=44C4B5D90188
    virtual ~CJoyUserList(void);

	//##ModelId=44C4B5D90196
    virtual void SortItem(CJoyListViewField* pField, JoyListViewSortType sortType);

	//##ModelId=44C4B5D901A5
    void ValidateFieldsByGameId(UINT gameId);
	//##ModelId=44C4B5D901B5
    void SetUserLadderText(CJoyLabel* textLabel, UINT userLadder);
public:
    DECLARE_MESSAGE_MAP()
	//##ModelId=44C4B5D901C5
    afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
};

#endif  // __USERLIST_H_CLIENT_MAIN__
